/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package lab6.Home;

import java.util.LinkedList;

/**
 *
 * @author THIEN
 * how to create linked list and some method for it
 */
public class LinkedLists {
    public static void main(String args[]){
        LinkedList<String> LList = new LinkedList<String>();
        /**
         * Method for linked list
         */
        LList.add("Happy");
        LList.add("My");
        LList.add("Birthday");
        LList.add("4-7");

        //remove theo string
        //LList.remove("My");
        //System.out.println("List content:"+LList);

        //remove theo index
        //LList.remove(0);
        //System.out.println("List content:"+LList);

        //doi vi tri
        String value1 = LList.get(1);
        String value2 = LList.get(3);
        LList.set(1, value2+" changed");
        LList.set(3, value1+" changed");

        System.out.println("List content:"+LList);
        //remove first and last
        LList.removeFirst();
        LList.removeLast();

        System.out.println("List content:"+LList);
    }

}
